**************************************************
************ LOAD AND PREP GRACE DATA ************
**************************************************
* get the name of the current data file in memory
_getfilename "`c(filename)'"
local GRACE_data_set = "GRACE_JOP_Replication_7_28_22.dta"
* if it doesn't match the GRACE data set, load the GRACE data
if "`r(filename)'" != "`GRACE_data_set'"{
    di in red "Got filename: `r(filename)', loading GRACE data set and replacing existing data set"
    use "data_files/GRACE_JOP_Replication_7_28_22.dta", replace
}

* now we check whether we have already run the necessary replication prep code
* we do this by looking for the ballot_mmd variable
* if it doesn't exist, run GRACE prep
capture confirm variable ballot_mmd
if _rc {
    di in red "running GRACE data prep do file"
    * needed for reproducing results for table 2
    set sortseed 1234
    quietly do "do_files/prep_GRACE_data/replication_prep.do"
}
else {
    di in red "already ran replication prep, continuing with the rest of the file"
} 
